function [ W1, H1 ] = TNMF( duomenys, R, niter)

    M = size(duomenys, 1);
    N = size(duomenys, 2);
    
    Y = duomenys;
    W1 = rand(M, R);
    H1 = rand(R, N);
    
    
    ee = 1e-6;
    
    for k=1:niter
        
        W1 = W1 .* (Y*H1' )./((W1*H1)*H1' + ee);
        H1 = H1 .* (W1'*Y )./(W1'*W1*H1 + ee);
        H1 = ApplyHConservaty(H1, R);
    end
    
    
end
